home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / ibm / loadall.arc / LOADALL.BAS < prev    next >
BASIC Source File  |  1990-07-10  |  18KB  |  597 lines

  1. '***************************************************************************
  2. '***************                                             ***************
  3. '***************                 LOADALL.BAS                 ***************
  4. '***************                                             ***************
  5. '***************************************************************************
  6. '
  7. '
  8. '
  9.  
  10.     DEFINT A-Z
  11.     REM $DYNAMIC
  12.     DIM PflHighlight(12), PflLin$(12), PflMssg$(12)
  13.     DIM WindMem(2000)                       ' Window manager memory
  14.     DIM PfbHighlight(12), PfbLin$(12)       ' Arrays for subprogram
  15.     DIM HelpLevel(12)
  16.     CLS
  17.     GOSUB DoMhtbInit
  18.     Dtaseg = VARSEG(WindMem(0))             ' Our reserved memory segment
  19.     IF Dtaseg = 0 THEN
  20.        CLS
  21.        BEEP
  22.        PRINT "You did not compute Dtaseg% correctly."
  23.        PRINT "Please look at the top of this program."
  24.        END
  25.     END IF
  26.  
  27.     IF Monitor = &HB800 THEN          ' If color monitor
  28.        BoxColr = 30                   ' Yellow on blue
  29.        FillColr = 23                  ' White on blue
  30.        HighColr = 28                  ' Red on blue
  31.        InverseColr = 121              ' Blue
  32.     ELSE                              ' Mono monitor
  33.        BoxColr = 7                    ' White on black
  34.        FillColr = 7                   ' Ditto
  35.        HighColr = 31                  ' Underlined high intensity white
  36.        InverseColr = 112              ' Black on white
  37.     END IF
  38.  
  39.     GOTO PickPart
  40.  
  41. '***********************************************
  42. '*
  43. '*     this is the put information on top line to pick from (lotus)
  44. '*
  45. '*******************************************
  46.  
  47. PickMainOption:
  48.     CLS
  49.     RESTORE Pick123Data
  50.     READ PflHighlight(0)              ' Number of elements
  51.     FOR N = 1 TO PflHighlight(0)
  52.         READ PflLin$(N), PflHighlight(N), PflMssg$(N)
  53.     NEXT
  54.     
  55.     PickLin = 3
  56.     LeftColumn = 1
  57.     RightColumn = 80
  58.     SelectionNumber = 1             ' Which one to start at
  59.     DisplayMessages = 1             ' Turn on message display
  60.     TerminatorChars$ = "TPL" + CHR$(27)' Highlight letter of each
  61.                     ' selection plus Esc
  62.     LOCATE 1, 1
  63.     PRINT "Please highlight your selection and ";
  64.     PRINT "press <Enter> or type in your selection";
  65.     LOCATE 2, 1
  66.     PRINT "Your selection: ";
  67.  
  68.     LOCATE 21, 1
  69.     PRINT "Part Selected   "; ShowPartType$
  70.  
  71.     InputLin = 2
  72.     InputColumn = POS(0)               ' current cursor position
  73.     GOSUB Display123
  74.     GOSUB DoPick123
  75.  
  76.  
  77.     LOCATE 10, 1
  78.     IF Kascii = 27 THEN
  79.        PRINT "You pressed 'Esc'"
  80.        GOTO ThatsAll
  81.        END
  82.     END IF
  83.     IF SelectionNumber THEN
  84.        PRINT "You chose ";
  85.        PRINT PflLin$(SelectionNumber)
  86.     ELSE
  87.        PRINT "You entered "; PflLin$(0)
  88.     END IF
  89.     IF SelectionNumber = 1 THEN GOTO TestConnection
  90.     IF SelectionNumber = 2 THEN GOTO PickPart
  91.     IF SelectionNumber = 3 THEN GOTO ProgBootLoader
  92.     
  93. '*********************** end routine *********************
  94.  
  95. '****************************
  96. '*
  97. '*   this is where pick part no. from a box
  98. '*
  99. '****************************
  100.  
  101. PickPart:
  102.     LOCATE 2, 25
  103.     PRINT "Select the part desired"
  104.     Box = 2                           ' Double line box
  105.     RESTORE PartBoxData
  106.     READ PfbHighlight(0)              ' Number of elements
  107.     FOR N = 1 TO PfbHighlight(0)
  108.         READ PfbLin$(N), PfbHighlight(N)
  109.     NEXT
  110.     TopRow = 10                       ' Boundaries of the box
  111.     LeftColumn = 1
  112.     BottomRow = 14
  113.     RightColumn = 40
  114.     SelectionNumber = 1                ' Which one to start at
  115.     TerminatorChars$ = "1AE9D" + CHR$(27)' Highlight letter of each
  116.                        ' part plus Esc
  117.     GOSUB PartBoxDisplay
  118.     GOSUB DoPickFromBox
  119.     LOCATE 20, 1
  120.     IF Kascii = 27 THEN
  121.        PRINT "You pressed 'Esc'"
  122.        GOTO ThatsAll
  123.     ELSE
  124.        PRINT "You chose selection number";
  125.        PRINT SelectionNumber, PfbLin$(SelectionNumber)
  126.     END IF
  127.  
  128.     ShowPartType$ = PfbLin$(SelectionNumber)
  129.     IF SelectionNumber = 1 THEN
  130.        PartType$ = "A1": ZeroFill = 256: ProgLen = 0
  131.        MSBBootAddress$ = "BF": LSBBootAddress$ = "40"
  132.        ProgPromFile$ = "PROGE9.MX"
  133.     END IF
  134.     IF SelectionNumber = 2 THEN
  135.        PartType$ = "A2": ZeroFill = 256: ProgLen = 0
  136.        MSBBootAddress$ = "BF": LSBBootAddress$ = "40"
  137.        ProgPromFile$ = "PROGE2.MX"
  138.     END IF
  139.     IF SelectionNumber = 3 THEN
  140.        PartType$ = "E2": ZeroFill = 256: ProgLen = 0
  141.        MSBBootAddress$ = "BF": LSBBootAddress$ = "40"
  142.        ProgPromFile$ = "PROGE2.MX"
  143.     END IF
  144.     IF SelectionNumber = 4 THEN
  145.        PartType$ = "E9": ZeroFill = 1000: ProgLen = 0
  146.        MSBBootAddress$ = "BF": LSBBootAddress$ = "40"
  147.        ProgPromFile$ = "PROGE9.MX"
  148.     END IF
  149.     IF SelectionNumber = 5 THEN
  150.        PartType$ = "D3": ZeroFill = 1000: ProgLen = 0
  151.        MSBBootAddress$ = "BF": LSBBootAddress$ = "46"
  152.        ProgPromFile$ = "PROGD3.MX"
  153.     END IF
  154.  
  155.  
  156.     GOTO PickMainOption
  157.  
  158. '***************** end routine ******************************
  159. '******************************************************************
  160. '*
  161. '*      this routine test the connection to selected part.
  162. '*
  163. '****************************************
  164. TestConnection:
  165. '        CLS
  166.     BytesSent = 0
  167.     LOCATE 11, 1
  168.     PRINT "Verifying connection to HC11"
  169.     LOCATE 13, 1
  170.     PRINT "         Please Wait"
  171. TESTxCONTROL:
  172.     OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  173.     Value = 255
  174.     PRINT #1, CHR$(Value);
  175.     IF ProgLen = 1 THEN
  176.         TransHexValue$ = "00": TransErrorCode = 0
  177.         GOSUB SENDxVALUE
  178.         IF TransErrorCode <> 1 THEN
  179.             PRINT "Connection (address step 1) failed."
  180.             GOTO ThatsAll
  181.         END IF
  182. '               IF TransErrorCode = 1 THEN PRINT "Connection step 1 (JMP) completed."
  183.         TransHexValue$ = "03": TransErrorCode = 0
  184.         GOSUB SENDxVALUE
  185.         IF TransErrorCode <> 1 THEN
  186.             PRINT "Connection (address step 2) failed."
  187.             GOTO ThatsAll
  188.         END IF
  189. '               IF TransErrorCode = 1 THEN PRINT "Connection step 2 (BF) completed."
  190.     END IF
  191.     TransHexValue$ = "7E": TransErrorCode = 0
  192.     GOSUB SENDxVALUE
  193.     IF TransErrorCode <> 1 THEN
  194.        PRINT "Connection step 1 (JMP) failed."
  195.        GOTO ThatsAll
  196.     END IF
  197. '        IF TransErrorCode = 1 THEN PRINT "Connection step 1 (JMP) completed."
  198.     TransHexValue$ = MSBBootAddress$: TransErrorCode = 0
  199.     GOSUB SENDxVALUE
  200.     IF TransErrorCode <> 1 THEN
  201.        PRINT "Connection step 2 "; MSBBootAddress$; " failed."
  202.        GOTO ThatsAll
  203.     END IF
  204. '        IF TransErrorCode = 1 THEN PRINT "Connection step 2 (BF) completed."
  205.     TransHexValue$ = LSBBootAddress$: TransErrorCode = 0
  206.     GOSUB SENDxVALUE
  207.     IF TransErrorCode <> 1 THEN
  208.        PRINT "Connection step 3 "; LSBBootAddress$; " failed."
  209.        GOTO ThatsAll
  210.     END IF
  211. '        IF TransErrorCode = 1 THEN PRINT "Connection step 3 (40) completed."
  212.     GOSUB FillZeros
  213.     CLOSE #1
  214.  
  215.     LOCATE 15, 1
  216.     PRINT "The HC11 is responding correctly."
  217.     INPUT "Hit Enter to continue "; CR$
  218.  
  219. '        CLS
  220.     GOTO PickMainOption
  221.  
  222. '************************ end routine ********************************
  223. '***********************************************************************
  224. '*
  225. '*                 program ram to program e2 eeprom
  226. '*
  227. '************************************************************
  228. ProgBootLoader:
  229.     LOCATE 11, 1
  230.     PRINT "Preparing HC11"
  231.     FileName$ = ProgPromFile$
  232.     BootLoad = 1
  233.     GOTO CheckFile
  234. ProgProm:
  235. '        LOCATE 11, 1
  236. '        PRINT "Programming HC11"
  237.     FirstRecordSent = 0
  238.     BootLoad = 0
  239.     LOCATE 13, 1
  240.     PRINT "                                                             "
  241.     PRINT "                                                             "
  242.     PRINT "                                                                          "
  243.     LOCATE 12, 1
  244.     INPUT "Enter file to be downloaded into PROM"; FileName$
  245. CheckFile:
  246.     RecordCount = 0
  247.     OPEN FileName$ FOR INPUT AS #2
  248. NoS1Records:
  249.     INPUT #2, record$
  250.     IF LEFT$(record$, 2) = "S0" THEN GOTO NoS1Records
  251.     IF LEFT$(record$, 2) = "S1" THEN
  252.         RecordCount = RecordCount + 1
  253.         GOTO NoS1Records
  254.     END IF
  255.     IF LEFT$(record$, 2) = "S9" THEN
  256.        IF RecordCount = 0 THEN
  257.           LOCATE 12, 1
  258.           PRINT "There are no S1 records in this file."
  259.           INPUT "Hit enter to continue"; CR$
  260.           GOTO PickMainOption
  261.        ELSE
  262.           GOTO SendFile
  263.        END IF
  264.     END IF
  265.     LOCATE 12, 1
  266.     PRINT "This file contains one or more none S19 records."
  267.     INPUT "Hit enter to continue"; CR$
  268.     GOTO PickMainOption
  269. SendFile:
  270.     CLOSE #2
  271.     LOCATE 13, 1
  272.     PRINT "File contains "; RecordCount; " S1 records."
  273.     OPEN FileName$ FOR INPUT AS #2
  274.     IF BootLoad = 1 THEN
  275.        OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  276.        Value = 255
  277.        PRINT #1, CHR$(Value);
  278.     END IF
  279.     IF BootLoad = 0 THEN
  280.        OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
  281.     END IF
  282.     BytesSent = 0
  283. GetRecord:
  284.     INPUT #2, record$
  285.     RecordType$ = LEFT$(record$, 2)
  286.     IF RecordType$ = "S0" THEN
  287. '           LOCATE 14, 1
  288. '           PRINT "Not transfering following S0 record."
  289. '           PRINT record$
  290.        GOTO GetRecord
  291.     END IF
  292.     IF RecordType$ = "S1" THEN
  293.        LOCATE 14, 1
  294.        PRINT "Transfering following S1 record."
  295.        PRINT record$
  296.        RecordLength$ = MID$(record$, 3, 2)
  297. '           PRINT "Record Length "; RecordLength$
  298.        RecordAddress$ = MID$(record$, 5, 4)
  299. '           PRINT "Record Address "; RecordAddress$
  300.        record$ = RIGHT$(record$, LEN(record$) - 8)
  301. '           PRINT "Data and Checksum "; record$
  302. '           INPUT "Hit RETURN to continue "; CR$
  303. SendFileLength:
  304.        IF FirstRecordSent = 1 THEN GOTO ParseAndSend
  305.        IF BootLoad = 0 THEN
  306.           TransErrorCode = 0
  307.           Value = RecordCount
  308.           GOSUB TRANSxVALUE
  309.           IF TransErrorCode <> 1 THEN
  310.          PRINT "Verification of file length failed."
  311.          GOTO ThatsAll
  312.           ELSE
  313.  '                PRINT "File length sent successfully."
  314.  '                INPUT "Hit enter to continue"; CR$
  315.           END IF
  316.        END IF
  317. ParseAndSend:
  318.        IF BootLoad = 1 THEN
  319.           TransErrorCode = 0
  320.           IF LEN(record$) > 2 THEN
  321.          TransHexValue$ = LEFT$(record$, 2)
  322.          record$ = RIGHT$(record$, LEN(record$) - 2)
  323.          GOSUB SENDxVALUE
  324.          IF TransErrorCode <> 1 THEN
  325.             PRINT "Verification failed."
  326.             PRINT "Successfully sent "; BytesSent - 1; " bytes."
  327.             GOTO ThatsAll
  328.          ELSE
  329. '                    PRINT ""; BytesSent; " bytes successfully sent."
  330.             GOTO ParseAndSend
  331.          END IF
  332.           ELSE
  333.          GOTO GetRecord
  334.           END IF
  335.        ELSE
  336. SendAddress:
  337.           TransErrorCode = 0
  338.           TransHexValue$ = LEFT$(RecordAddress$, 2)
  339.           GOSUB SENDxVALUE
  340.           IF TransErrorCode <> 1 THEN
  341.          PRINT "Verification of MSB of address failed."
  342.          GOTO ThatsAll
  343.           ELSE
  344. '                 PRINT "MSB of address sent successfully."
  345. '                 INPUT "Hit enter to continue"; CR$
  346.           END IF
  347.           TransHexValue$ = RIGHT$(RecordAddress$, 2)
  348.           GOSUB SENDxVALUE
  349.           IF TransErrorCode <> 1 THEN
  350.          PRINT "Verification of LSB of address failed."
  351.          GOTO ThatsAll
  352.           ELSE
  353. '                 PRINT "LSB of address sent successfully."
  354. '                 INPUT "Hit enter to continue"; CR$
  355.           END IF
  356. SendRecordLength:
  357.           TransHexValue$ = RecordLength$
  358.           GOSUB SENDxVALUE
  359.           IF TransErrorCode <> 1 THEN
  360.          PRINT "Verification of record length failed."
  361.          GOTO ThatsAll
  362.           ELSE
  363. '                 PRINT "Record length sent successfully."
  364. '                 INPUT "Hit enter to continue"; CR$
  365.           END IF
  366. SendData:
  367.           IF LEN(record$) > 2 THEN
  368.          TransHexValue$ = LEFT$(record$, 2)
  369.          record$ = RIGHT$(record$, LEN(record$) - 2)
  370.          GOSUB SENDxVALUE
  371.          IF TransErrorCode <> 1 THEN
  372.             PRINT "Verification failed."
  373.             PRINT "Successfully sent "; BytesSent - 1; " bytes."
  374.             GOTO ThatsAll
  375.          ELSE
  376. '                    PRINT ""; BytesSent; " bytes successfully sent."
  377.             GOTO SendData
  378.          END IF
  379.           ELSE
  380.          FirstRecordSent = 1
  381.          GOTO GetRecord
  382.           END IF
  383.        END IF
  384.     END IF
  385.     IF RecordType$ = "S9" THEN
  386.        IF BootLoad = 1 THEN
  387.           GOSUB FillZeros
  388.           CLOSE #1
  389.           CLOSE #2
  390.           BootLoad = 0
  391.           LOCATE 11, 1
  392.           PRINT "RAM ready to program PROM."
  393. '              INPUT "Hit enter to continue "; CR$
  394.           GOTO ProgProm
  395.        ELSE
  396.         ' transfer starting address see HC11EVM manual pA2 S9 records.
  397.           CLS
  398.           PRINT "PROM has been programmed and should be running program."
  399.           PRINT "To continue using this program the HC11 must be reset."
  400.           INPUT "Would you like to continue with this program"; CR$
  401.           IF CR$ = "Y" OR CR$ = "y" THEN
  402.         CLOSE
  403.         GOTO PickMainOption
  404.           END IF
  405.           PRINT
  406.           PRINT "GOODBYE"
  407.           GOTO WhatNext
  408.        END IF
  409.     ELSE
  410.        PRINT "A Non S19 record has been encountered. Abort Download."
  411.        GOTO ThatsAll
  412.     END IF
  413. WhatNext:
  414.        ' download finished. what now?
  415. ThatsAll:
  416.     CLOSE
  417.     END
  418.  
  419. '*******************************************************************************
  420. '*****************************************************************************
  421. '*
  422. '*                          SUBROUTINES
  423. '*
  424. '*****************************************************************************
  425. '*****************************************************************************
  426.  
  427. '*******************************************************************************
  428. '*
  429. '*             This routine fills RAM with 0's for bootstrap.
  430. '*
  431. '*
  432. '*******************************************************************************
  433. FillZeros:
  434. TransHexValue$ = "00": TransErrorCode = 0
  435. IF ZeroFill = 1000 THEN GOTO FillDone
  436. IF ZeroFill - BytesSent = 0 THEN GOTO FillDone
  437. IF ZeroFill - BytesSent < 0 THEN PRINT "OverFilled RAM during Bootstrap load."
  438. FOR I = BytesSent + 1 TO ZeroFill - 1
  439. GOSUB SENDxVALUE
  440. IF TransErrorCode <> 1 THEN
  441.          PRINT "Connection step "; I; " (00) failed.     Step "; I
  442.          GOTO ThatsAll
  443. END IF
  444. 'IF TransErrorCode = 1 THEN
  445. '             PRINT "Connection step "; I; " (00) completed."
  446. 'END IF
  447. NEXT I
  448. Value = 0
  449. PRINT #1, CHR$(Value);
  450. 'PRINT "Connection step 256 sent and assumed completed."
  451. FillDone:
  452. RETURN
  453.  
  454. '*******************************************************************************
  455. '*
  456. '*
  457. '*  Call into this routine with parameter TransHexValue = string of two
  458. '*     characters constsiting of the byte in hex to be sent
  459. '*  Routine also increments BytesSent
  460. '*
  461. '*******************************************************************************
  462. SENDxVALUE:
  463. TESTxCOUNT = 1
  464. FirstByteLoop = 0
  465. ConvertValue:
  466. Nibble$ = LEFT$(TransHexValue$, 1)
  467. GOSUB NibbleConvert
  468. MSBNibble = Nibble * 16
  469. Nibble$ = RIGHT$(TransHexValue$, 1)
  470. GOSUB NibbleConvert
  471. Value = MSBNibble + Nibble
  472. TRANSxVALUE:
  473. PRINT #1, CHR$(Value);
  474. TESTxLOOP1:
  475. IF NOT EOF(1) THEN
  476.     INP$ = INPUT$(LOC(1), #1)
  477.     VAL1 = ASC(INP$)
  478.     IF VAL1 = Value THEN
  479. '                PRINT "Value Recieved Correctly"
  480.         TransErrorCode = 1
  481.         BytesSent = BytesSent + 1
  482.         GOTO TESTxDONE
  483.     ELSE
  484.         IF BytesSent = 0 AND FirstByteLoop = 0 THEN
  485.             FirstByteLoop = 1
  486.             GOTO TESTxLOOP1
  487.         END IF
  488.         PRINT "Value Returned Wrong"
  489.         PRINT "Value Sent = "; Value
  490.         PRINT "Value Received from HC11 ="; VAL1
  491.         INPUT "Hit Return to End"; CR$
  492.         TransErrorCode = 0
  493.         GOTO TESTxDONE
  494.     END IF
  495. ELSE
  496.     TESTxCOUNT = TESTxCOUNT + 1
  497.     IF TESTxCOUNT > 10000 THEN
  498.         PRINT "HC11 NOT RESPONDING TO VALUE"
  499.         GOTO TESTxDONE
  500.     ELSE
  501.         GOTO TESTxLOOP1
  502.     END IF
  503. END IF
  504.  
  505. TESTxDONE:
  506. RETURN
  507.  
  508. '*******************************************************************************
  509. '*
  510. '*
  511. '*                Converts A to 10, B to 11 etc.
  512. '*
  513. '*
  514. '****************************************************
  515. NibbleConvert:
  516. Nibble = VAL(Nibble$)
  517. IF Nibble$ = "A" THEN Nibble = 10
  518. IF Nibble$ = "B" THEN Nibble = 11
  519. IF Nibble$ = "C" THEN Nibble = 12
  520. IF Nibble$ = "D" THEN Nibble = 13
  521. IF Nibble$ = "E" THEN Nibble = 14
  522. IF Nibble$ = "F" THEN Nibble = 15
  523. RETURN
  524.  
  525. '*******************************************************************************
  526. '*
  527. '*      include files for display routines.
  528. '*
  529. '*
  530. '***********************
  531.  
  532.     REM $INCLUDE: 'MhtbInit.cal'
  533.     REM $INCLUDE: 'Pick123.cal'
  534.     REM $INCLUDE: 'Pickbox.cal'
  535.       
  536.  
  537. '*******************************************************************************
  538. '*
  539. '*      information for pick from top line (lotus) routines
  540. '*
  541. '*
  542. '***********************
  543.  
  544. Pick123Data:            ' Each choice has a number indicating which character
  545.             ' should be highlighted for the selection. Note that
  546.             ' since we have two fruits beginning with "P", we
  547.             ' used "s" as the highlight character for "Pears".
  548.             
  549.             ' The message accompanying the selection follows
  550.             ' the number indicating the highlight letter.
  551.     DATA 3
  552.     DATA Test,    1,Verify connection to selected part.
  553.     DATA Pick,    1,Choose target part.
  554.     DATA Load,    1,Load/Program selected part.
  555.     
  556. Display123:
  557.     LOCATE 22, 1
  558.     PRINT "Use the right/left/up/down/PgUp/PgDn keys to select"
  559.     PRINT "an item and then press <Enter>. Press 'Esc' to cancel."
  560.     RETURN
  561.  
  562. '*******************************************************************************
  563. '*
  564. '*       information for pick from part selection box routines
  565. '*
  566. '*
  567. '********************
  568. PartBoxData:
  569.     DATA 5
  570.     DATA MC68HC11A1,10
  571.     DATA MC68HC811A2,10
  572.     DATA MC68HC811E2,10
  573.     DATA MC68HC711E9,11
  574.     DATA MC68HC711D3,10
  575.     
  576. PartBoxDisplay:
  577.     LOCATE 22, 1
  578.     PRINT "Use the right/left/up/down/PgUp/PgDn keys to select"
  579.     PRINT "an item and then press <Enter>. Press 'Esc' to cancel."
  580.     RETURN
  581.  
  582.  
  583.  
  584. END
  585. '
  586. '
  587. '
  588. '
  589. '
  590. '***************************************************************************
  591. '***************                                             ***************
  592. '***************                  END ROUTINE                ***************
  593. '***************                                             ***************
  594. '***************************************************************************
  595.  
  596.  
  597.